package com.pcy.project.rpc;

import com.alibaba.fastjson.JSONObject;
import com.pcy.project.Constants;
import com.pcy.project.bean.HotVideo;
import com.pcy.project.bean.HotVideoCommon;
import com.pcy.project.request.HttpUtils;

import java.util.List;

/**
 * @author: 清秋
 * @email:
 * @datetime: 16:28 2021/12/8
 * @Description:
 */
public class HotVideoService {
    /**
     * 该方法用于获取热门数据，并将热门数据返回
     *
     * @return
     */
    public List<HotVideo> getHotVideo() {
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=20";
        String result = HttpUtils.get( url );
        System.out.println( result );

        //json解析
        HotVideoCommon videoCommon = JSONObject.parseObject( result, HotVideoCommon.class );
        System.out.println( videoCommon.result.size() );

        return videoCommon.result;
    }
}
